package com.sunrise.xdoc.entity.catalog;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.sunrise.xdoc.entity.AbstractCodeEntity;
import com.sunrise.xdoc.entity.config.UploadFile;

@Entity
@Table(name = "catalog_san_pham")
@Inheritance(strategy = InheritanceType.JOINED)
public class SanPham extends AbstractCodeEntity {
	private static final long serialVersionUID = 1L;
	private String name;
	private LoaiSanPham loaiSP;
	private String thongTin;
	private UploadFile hinhAnh;
	private DonViTinh donViTinh;
	private Long donGia;
	// Chi co the ban san pham isActive.
	private boolean active = false;

	@Column(name = "name", unique = true)
	@Length(max = 250)
	@NotBlank(message = "Vui lòng điền tên sản phẩm")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne
	@JoinColumn(name = "loai_sp_id")
	public LoaiSanPham getLoaiSP() {
		return loaiSP;
	}

	public void setLoaiSP(LoaiSanPham loaiSP) {
		this.loaiSP = loaiSP;
	}

	@Column(name = "thong_tin")
	@Length(max = 512)
	public String getThongTin() {
		return thongTin;
	}

	public void setThongTin(String thongTin) {
		this.thongTin = thongTin;
	}

	@ManyToOne
	@JoinColumn(name = "hinh_anh_id")
	public UploadFile getHinhAnh() {
		return hinhAnh;
	}

	public void setHinhAnh(UploadFile hinhAnh) {
		this.hinhAnh = hinhAnh;
	}

	@ManyToOne
	@JoinColumn(name = "don_vi_tinh_id")
	public DonViTinh getDonViTinh() {
		return donViTinh;
	}

	public void setDonViTinh(DonViTinh donViTinh) {
		this.donViTinh = donViTinh;
	}

	@Column(name = "is_active")
	public boolean isActive() {
		return active;
	}

	public void setActive(boolean isActive) {
		this.active = isActive;
	}

	@Column(name = "don_gia")
	public Long getDonGia() {
		return donGia;
	}

	public void setDonGia(Long donGia) {
		this.donGia = donGia;
	}
}
